<template>
  <header class="header">
    <h1>todos</h1>
    <input class="new-todo" @keyup.enter="addTodo" v-model="name" placeholder="What needs to be done?">
  </header>
</template>

<script>
export default {
  data () {
    return {
      name: ''
    }
  },
  methods: {
    addTodo () {
      if (!this.name) return
      this.$store.commit('addTodo', this.name)
      this.name = ''
    }
  }
}
</script>

<style>

</style>
